﻿using System;

namespace ParamterSpecLearn
{
    class Program
    {

        /*yout 关键字功能*/
        static void Split(string name, out string firstName, out string lastName)
        {
            int i = name.LastIndexOf(' ');
            firstName = name.Substring(0, i);
            lastName = name.Substring(i + 1);
        }

        static void Main(string[] args)
        {

            Split("Joey Dong", out string a, out _);
            Console.WriteLine($"fistname{a}");


        }




        //按照应用传递的实际含义
        //static int x;
        //static void Main(string[] args)
        //{
        //    int a = default;
        //    Console.WriteLine(a);
        //    // foo(out x);
        //}

        //static void foo(out int y)
        //{
        //    Console.WriteLine(x);
        //    y = 1;
        //    Console.WriteLine(x);
        //}


        //params修饰符
        /* static int Sum (params int[] ints)
         {
             int sum = 0;
             for (int i = 0; i < ints.Length; i++)
             {
                 sum += ints[i];
             }
             return sum;

         }

         static void Main()
         {
             int total = 0;
             total = Sum(1, 2, 3, 4);
             Console.WriteLine(total);
         }*/

        /*   //可选参数
           static void Foo(int x = 23) { Console.WriteLine("我执行了"+x); }

           static void Main()
           {
               Foo();
           }
   */
        //static void Foo(int x, int y)
        //{
        //    Console.WriteLine(x + "," + y);
        //}

        //static void Main()
        //{
        //    Foo(y: 10, x: 5);
        //}
    }
}
